package com.example.kotlindemo

import com.example.kotlindemo.`interface`.apply
import java.io.File
import java.time.LocalDate
import java.time.Period


val _yesterday = 1.days.ago  //dsl 写法

//变体1: 相改成扩展函数
val yesterday = 1.days().ago()

//继续变体2
fun Int.days() = Period.ofDays(this)
fun Period.ago() = LocalDate.now() - this

//继续变体3:将扩展函数修改为扩展属性的方式
val Int.days:Period
    get() = Period.ofDays(this)

val Period.ago:LocalDate
    get() = LocalDate.now() - this

 val file = File("www").apply {

 }

//infix 修饰符 代表 这个函数支持中缀表达式

//infix fun Any.to(that:Any) = Pair(this,that)
//"key" to "value"  等同于  "key.to("value")

var str = "key" to "value"
var str2 = "key".to("value")



class Person(val name:String){
    operator fun invoke(){
        println("my name is $name")
    }
}

val person = Person("geniusmart")
//person()

object 前
infix fun Int.天(ago:前) = LocalDate.now() - Period.ofDays(this)
